import { createStore } from 'vuex'
import number from './modules/number'
import getters from './getters'

export default createStore({
  modules: {
    number
  },
  state: {
    count: 0
  },
  mutations: {
    SET_COUNT: (state, count) => {
      state.count = count
    }
  },
  actions: {
    increment({ commit, state, dispatch }) {
      state.count++
      commit('SET_COUNT', state.count)
    },
    logCount({ commit, state, dispatch }) {
      dispatch('extraFun')
    },
    extraFun({ commit, state, dispatch }) {
      console.log(state.count)
    },
    increNum({ commit, state, dispatch }) {
      dispatch('number/addNum')
    }
  },
  getters
})
